public class Buffer extends Queue {
  public Buffer(int n) { super(n); }
  public synchronized boolean put(Object x) {
    while ( isFull() ) try {
      wait();
    } catch (InterruptedException e) {
    	System.out.println(e); }
    super.put(x);
    notifyAll();
    return true;
  }
  public synchronized Object get() {
    while ( isEmpty() ) try {
      wait();
    } catch (InterruptedException e) {
      System.out.println(e); }
    Object tmp = super.get();
    notifyAll();
    return tmp;
  }
}